package com.api.user.controller;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.core.response.ResultGenerator;
import com.api.user.model.GameCategory;
import com.api.user.service.GameCategoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
import com.api.core.annotation.PowerEnable;
import io.swagger.annotations.*;



/**
* Created by wanghuiwen on 2021/04/15.
*/
@PowerEnable(name = "游戏分类",url = "/game/category")
@Api(value = "游戏分类", tags = {"游戏分类"})
@RestController
@RequestMapping("/game/category")
public class GameCategoryController extends Ctrl{
    @Resource
    private GameCategoryService gameCategoryService;

    @ApiOperation(value = "游戏分类添加", tags = {"游戏分类"}, notes = "游戏分类添加")
    @PostMapping(value="/add",name="游戏分类添加")
    public Result add(@ApiParam GameCategory gameCategory) {
        gameCategoryService.save(gameCategory);
        return ResultGenerator.genSuccessResult();
    }

    @ApiOperation(value = "游戏分类删除", tags = {"游戏分类"}, notes = "游戏分类删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id",required=true, value = "游戏分类id", dataType = "Long", paramType = "query")
    })
    @PostMapping(value="/delete",name="游戏分类删除")
    public Result delete(@RequestParam Long id) {
        gameCategoryService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @ApiOperation(value = "游戏分类修改", tags = {"游戏分类"}, notes = "游戏分类修改,对象主键必填")
    @PostMapping(value="/update",name="游戏分类修改")
    public Result update(@ApiParam GameCategory gameCategory) {
        gameCategoryService.update(gameCategory);
        return ResultGenerator.genSuccessResult();
    }

    @ApiOperation(value = "游戏分类列表信息", tags = {"游戏分类"}, notes = "游戏分类列表信息")
    @PostMapping(value = "/list", name = "游戏分类列表信息")
    public Result list() {
        return gameCategoryService.list();
    }
}
